<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/9/11
  Time: 15:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>Sheraton酒店管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/public.css" media="all" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui_ext/dtree/dtree.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui_ext/dtree/font/dtreefont.css">
</head>
<body class="childrenBody">
<!-- 搜索条件开始 -->
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>账号查询</legend>
</fieldset>

<form class="layui-form" method="post" id="searchFrm1">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">客户昵称:</label>
            <div class="layui-input-inline" style="padding: 5px">
                <input type="text" name="loginName"  autocomplete="off" class="layui-input layui-input-inline"
                       placeholder="请输入客户昵称" style="height: 30px;border-radius: 10px">
            </div>
            <label class="layui-form-label">房号:</label>
            <div class="layui-input-inline" style="padding: 5px">
                <input type="text" name="hId2" autocomplete="off" class="layui-input layui-input-inline"
                       placeholder="请输入房号" style="height: 30px;border-radius: 10px">
            </div>
        </div>

        <div class="layui-inline" style="text-align: center">
            <button type="button"
                    class="layui-btn layui-btn-normal layui-icon layui-icon-search layui-btn-radius layui-btn-sm"
                    lay-submit  lay-filter="doSearch1" style="margin-top: 4px">查询
            </button>
            <button type="reset"
                    class="layui-btn layui-btn-warm layui-icon layui-icon-refresh layui-btn-radius layui-btn-sm"
                    style="margin-top: 4px">重置
            </button>
        </div>
    </div>
</form>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">

</fieldset>
<form class="layui-form" method="post" id="searchFrm">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">房号:</label>
            <div class="layui-input-inline" style="padding: 5px">
                <input type="text" name="hId" autocomplete="off" class="layui-input layui-input-inline"
                       placeholder="请输入房号" style="height: 30px;border-radius: 10px">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">房间类型:</label>
            <div class="layui-input-inline" style="padding: 5px">
                <input type="text" name="hotelType" autocomplete="off" class="layui-input layui-input-inline"
                       placeholder="请输入房间类型" style="height: 30px;border-radius: 10px">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">房间价格区间:</label>
            <div class="layui-input-inline" style="padding: 5px">
                <input type="text" name="lowPrice" autocomplete="off" class="layui-input layui-input-inline"
                       style="height: 30px;border-radius: 10px">
            </div>

            <div class="layui-input-inline" style="padding: 5px">
                <input type="text" name="highPrice" autocomplete="off" class="layui-input layui-input-inline"
                       style="height: 30px;border-radius: 10px">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">是否预订:</label>
            <div class="layui-input-inline">
                <input type="radio" name="ifRenting" value="1" title="已预订">
                <input type="radio" name="ifRenting" value="0" title="未预订">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-black" style="text-align: center">
            <button type="button"
                    class="layui-btn layui-btn-normal layui-icon layui-icon-search layui-btn-radius layui-btn-sm"
                    lay-submit  lay-filter="doSearch" style="margin-top: 4px">查询
            </button>
            <button type="reset"
                    class="layui-btn layui-btn-warm layui-icon layui-icon-refresh layui-btn-radius layui-btn-sm"
                    style="margin-top: 4px">重置
            </button>
        </div>
    </div>
</form>
<!-- 搜索条件结束 -->
<table id="roomTable" lay-filter="roomTable"></table>


<script id="barRoom" type="text/html">
    <a class="layui-btn layui-btn-xs layui-btn-radius" lay-event="rent">房间更换</a>
    <a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-radius" lay-event="showImg">查看大图</a>
</script>

<%--查看大图弹出的层开始--%>
<div id="viewRoomImageDiv" style="display: none;text-align: center">
    <img alt="房间图片" width="700px" height="310px" id="view_roomimg">
</div>

<!-- 添加和修改的弹出层-->
<div style="display: none;padding: 20px" id="saveOrUpdateDiv">
    <form class="layui-form layui-row layui-col-space10" lay-filter="dataFrm" id="dataFrm">
        <div class="layui-col-md12 layui-col-xs12">
            <div class="layui-row layui-col-space10">
                <div class="layui-col-md9 layui-col-xs7">
                    <div class="layui-form-item magt3">
                        <label class="layui-form-label">账单流水号:</label>
                        <div class="layui-input-block" style="padding: 5px">
                            <input type="text" name="checkId" id="checkId" autocomplete="off" class="layui-input"
                                   lay-verify=""
                                   placeholder="请输入账单流水号" style="height: 30px;border-radius: 10px" readonly="readonly">
                        </div>
                    </div>
                    <div class="layui-form-item magt3">
                        <label class="layui-form-label">客户昵称:</label>
                        <div class="layui-input-block" style="padding: 5px">
                            <input type="text" name="loginName1" id="loginName1" autocomplete="off" class="layui-input"
                                   lay-verify=""
                                   placeholder="请输入客户昵称" style="height: 30px;border-radius: 10px" readonly="readonly">
                        </div>
                    </div>
                    <div class="layui-form-item magt3">
                        <label class="layui-form-label">电话号:</label>
                        <div class="layui-input-block" style="padding: 5px">
                            <input type="text" name="phone" id="phone" autocomplete="off" class="layui-input"
                                   lay-verify=""
                                   placeholder="请输入电话号" style="height: 30px;border-radius: 10px" readonly="readonly">
                        </div>
                    </div>
                    <div class="layui-form-item magt3">
                        <label class="layui-form-label">原房间号:</label>
                        <div class="layui-input-block" style="padding: 5px">
                            <input type="text" name="hId" id="hId" autocomplete="off" class="layui-input"
                                   lay-verify=""
                                   placeholder="请输入原房间号" style="height: 30px;border-radius: 10px" readonly="readonly">
                        </div>
                    </div>
                    <div class="layui-form-item magt3">
                        <label class="layui-form-label">房间设施有无损坏:</label>
                        <div class="layui-input-block" style="padding: 5px">
                            <input type="text" name="problem" id="problem" autocomplete="off" class="layui-input"
                                   lay-verify=""
                                   placeholder="房间设施有无损坏" style="height: 30px;border-radius: 10px">
                        </div>
                    </div>
                    <div class="layui-form-item magt3">
                        <label class="layui-form-label">现房间号:</label>
                        <div class="layui-input-block" style="padding: 5px">
                            <input type="text" name="hId1" id="hId1" autocomplete="off" class="layui-input"
                                   lay-verify=""
                                   placeholder="请输入更换后的房间号" style="height: 30px;border-radius: 10px" readonly="readonly">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">房间类型:</label>
                        <div class="layui-input-block" style="padding: 5px">
                            <input type="text" name="hotelType" id="hotelType" autocomplete="off" class="layui-input"
                                   placeholder="请输入房间类型" style="height: 30px;border-radius: 10px" readonly="readonly">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">可住人数:</label>
                        <div class="layui-input-block" style="padding: 5px">
                            <input type="text" name="number" id="number" autocomplete="off" class="layui-input"
                                   placeholder="请输入房间可住人数" style="height: 30px;border-radius: 10px">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">房间价格:</label>
                        <div class="layui-input-block" style="padding: 5px">
                            <input type="text" name="price" id="price" autocomplete="off" class="layui-input"
                                   placeholder="请输入房间价格" style="height: 30px;border-radius: 10px" readonly="readonly">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">支付款:</label>
                        <div class="layui-input-block" style="padding: 5px">
                            <input type="text" name="payMoney" id="payMoney" autocomplete="off" class="layui-input"
                                   placeholder="请输入支付款" style="height: 30px;border-radius: 10px" >
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item magb0">
                <div class="layui-input-block" style="text-align: center;padding-right: 120px">
                    <button
                            class="layui-btn layui-btn-normal layui-btn-md layui-icon layui-icon-release layui-btn-radius"
                            lay-filter="doSubmit" lay-submit="">提交
                    </button>
                    <button type="reset"
                            class="layui-btn layui-btn-warm layui-btn-md layui-icon layui-icon-refresh layui-btn-radius">
                        重置
                    </button>
                </div>
            </div>
        </div>
    </form>
</div>
<%-- 添加或者修改弹出框结束 --%>

<script type="text/javascript" src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/index.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/cache.js"></script>
<script>
    var tab;
    layui.use(
        ['table', 'layer', 'form', 'jquery','upload'], function () {
            var table = layui.table;
            var form = layui.form;
            var $ = layui.jquery;
            var layer = layui.layer;
            var upload=layui.upload;
            // var dtree = layui.dtree;



            var index;
            var url;
            table.on('tool(roomTable)', function (obj) {
                var data = obj.data
                if (obj.event == "rent") { // 编辑
                    rentRoom(data)
                }else if(obj.event=="showImg"){
                    //查看大图
                    showImg(data)
                }
            })
            form.on('submit(doSearch1)',function(data){
                var param = $("#searchFrm1").serialize()
                $.get("${pageContext.request.contextPath}/room/infoCheck?"+param,function(r){
                   if(r.code==0) {
                       layer.msg(r.msg)
                       return false
                   }
                       $("#loginName1").val(data.field.loginName)
                       tab = table.render({
                           elem: '#roomTable',
                           url: "${pageContext.request.contextPath}/room/roomShow",
                           cellMinWidth: 30,
                           page: {limit: 5, limits: [5, 10, 15, 20]},
                           // toolbar: '#toolbarRoom',//开启头部工具栏，并为其绑定左侧模板
                           cols: [[
                               {type: 'checkbox', fixed: 'left'}
                               ,{field: 'hId', width: 150, title: '房间号', sort: true}
                               ,{field: 'hotelType', width: 150, title: '房间类型', sort: true}
                               , {field: 'price', width: 100, title: '房间价格'}
                               ,{field: 'ifRenting', width: 120, title: '是否预订', sort: true,templet: function (data) {
                                       return data.ifRenting == 1 ? '已预订' : '未预订'
                                   }}
                               ,{field: 'description', width: 130, title: '房间描述', sort: true}
                               ,{field: 'createtime', width: 180, title: '创建时间', sort: true}
                               , {fixed: 'right', title: '操作', toolbar: '#barRoom'}
                           ]]
                       })
                                   })
            })

            form.on('submit(doSearch)', function (data) {
                //ajax数据
                tab.reload({
                    where: data.field
                })
                //不跳转页面
                return false;
            })

            form.on('submit(doSubmit)',function(r){
                var param = $("#dataFrm").serialize()
                layer.confirm("确定要提交该数据么", function (r) {
                    $.get("${pageContext.request.contextPath}/room/changeRoom?"+param,function (r) {
                        layer.msg(r.msg)
                        layer.close(index)
                        tab.reload()
                    })
                })
                return false;
            })

            function rentRoom(data){
                $.post("${pageContext.request.contextPath}/room/generateInfo",function(r){
                    index=layer.open({
                        type: 1,
                        title:'房间更换',
                        content:$("#saveOrUpdateDiv"),
                        area: ['800px', '440px'],
                        success:function() {
                            $("#checkId").val(r.data.checkId)
                            $("#hId").val(r.data.hId)
                            $("#phone").val(r.data.phone)
                            $("#price").val(data.price)
                            $("#hotelType").val(data.hotelType)
                            $("#hId1").val(data.hId)
                            $("#payMoney").val(data.payMoney)
            }
        })
                    // $("#identity1").val(r.data.identity)
                    // $("#")
                })

            }


            function showImg(data){
                index=layer.open({
                    type: 1,
                    title:'房间大图',
                    content:$("#viewRoomImageDiv"),
                    area: ['800px', '400px'],
                    success:function(){
                        $("#view_roomimg").attr("src",data.hotelImg)
                    }
                })
            }



            <%--var roleTable--%>

            <%--function selUserRole(data) {--%>
            <%--// 弹出框--%>
            <%--index = layer.open({--%>
            <%--type: 1 // 1（页面层）--%>
            <%--, title: "分配" + data.realname + "的角色"--%>
            <%--, content: $("#selUserRoleDiv")--%>
            <%--, area: ['600px', '380px']--%>
            <%--, btn: ['<div class="layui-icon layui-icon-release">确认分配</div>'--%>
            <%--, '<div class="layui-icon layui-icon-close">取消分配</div>']--%>
            <%--, btnAlign: 'c'--%>
            <%--, success: function () {--%>
            <%--// 给roleTable赋值--%>
            <%--roleTable = table.render({--%>
            <%--elem: "#roleTable"--%>
            <%--, url: "${pageContext.request.contextPath}/user/findRoleByUser?userid=" + data.userid--%>
            <%--// ,page: {limit:5 ,limits:[5,10,15]} //开启分页--%>
            <%--, cellMinWidth: 80--%>
            <%--, cols: [[ //表头--%>
            <%--{type: 'checkbox', fixed: 'left'}--%>
            <%--, {field: 'roleid', title: '角色ID', fixed: 'center'}--%>
            <%--, {field: 'rolename', title: '角色名称', fixed: 'center'}--%>
            <%--, {field: 'roledesc', title: '角色描述', fixed: 'center'}--%>
            <%--]]--%>
            <%--})--%>
            <%--}--%>
            <%--, yes: function (obj) {--%>
            <%--var checkStatus = table.checkStatus("roleTable");--%>
            <%--if (checkStatus.data.length == 0) {--%>
            <%--layer.msg("至少选择一个")--%>
            <%--} else {--%>
            <%--// 获取用户id--%>
            <%--var userid = data.userid--%>
            <%--var param = "userid=" + userid--%>

            <%--// 循环选中的内容nodes--%>
            <%--$.each(checkStatus.data, function (i, item) {--%>
            <%--param += "&ids=" + item.roleid--%>
            <%--})--%>
            <%--// A=valueA&B=valueB&B=valueB--%>
            <%--// 把数据保存到数据库--%>
            <%--$.get("${pageContext.request.contextPath}/user/saveRoleUser?"+param, function (r) {--%>
            <%--layer.msg(r.msg)--%>
            <%--})--%>
            <%--}--%>
            <%--layer.close(index)--%>
            <%--}--%>
            <%--})--%>
            <%--}--%>


        })

</script>
</body>
</html>

